package uy.edu.ort.negocio;

import java.util.logging.Level;
import java.util.logging.Logger;
import uy.edu.ort.cliente.Utils;
import uy.edu.ort.interfaces.IPersistencia;

/**
 *
 * @author 153287 - 154559
 */
public class Persistencia {

    static IPersistencia p;

    private Persistencia() {
    }

    public static IPersistencia ObtenerPersistencia() {
        if (p == null) {
            String className = Utils.getPropertiesValue("className");
            try {
                p = (IPersistencia) Class.forName(className).newInstance();
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
        return p;
    }
}
